import * as types from '../types'
import {Tools} from "../../lib/tools";

const state = {
    popupVisible: false,
    nextBtnDisabled: true,
    ChooseName: "",
    OppName: '',
    phoneNumber: '请填写法人有效手机号码(必填)',
    LegalPersonNamePlaceholder: '请填写法人姓名(必填)',
    IDNumberPlaceholder: '请填写法人身份证号(必填)',
    placeholderEmail: '请填写法人邮箱(必填)',
    phoneNumberData: "",
    LegalPersonNameData: "",
    IDNumberData: "",
    emailData: "",
    expirationDate: [
        {name: 'expirationDate', content: '身份证有效期', all: '请选择有效期(必填)', choose: ''},
    ],
    occupation: [
        {name: 'occupation', content: '职业', all: '请选择法人所属职业(选填)', choose: ''}
    ],
    slotData: [
        {
            flex: 1,
            values: [],
            className: 'slot1',
            textAlign: 'center',
        },
    ],

}

const getters = {}

const actions = {}

const mutations = {
    [types.AUTHENTICATION_SHOW_SELECT_LIST](state, value) {
        state.popupVisible = !state.popupVisible
        state.OppName = value;
        if (value == 'expirationDate') {
            state.ChooseName = '身份有效期';
            state.slotData[0].values = ['2020年', '2021年', '2022年', '2023年', '2024年', '2025年', '2026年',
                '2027年', '2028年']
        } else if (value == 'occupation') {
            state.ChooseName = '职业';
            state.slotData[0].values = ['各类专业技术人员', '国家机关、党群组织、企事业单位的负责人', '办事人员和有关人员',
                '商业工作人员', '服务性工作人员', '农林牧渔劳动者', '生产工作、运输工作和部分体力劳动者', '不便分类的其他劳动者']
        }
    },
    [types.AUTHENTICATION_SELECT_CANCEL](state) {
        state.popupVisible = !state.popupVisible
    },
    [types.AUTHENTICATION_SELECT_CHANGE](state) {
        state.popupVisible = false
    },

    [types.AUTHENTICATION_GET_INPUT_VALUE](state, value) {
        state.InputValue = value
    },
    [types.GET_PHONE_NUMBER_VALUE](state, value) {
        state.phoneNumberData = value
    },
    [types.GET_LEGAL_PERSON_NAME_VALUE](state, value) {
        state.LegalPersonNameData = value
    },
    [types.GET_ID_NUMBER_VALUE](state, value) {
        state.IDNumberData = value
    },
    [types.GET_EMAIL_VALUE](state, value) {
        state.emailData = value
    },
    [types.AUTHENTICATION_NEXT_BUTTON_CHECK](state) {
        if (Tools.check.isEmpty(state.LegalPersonNameData) ||
            Tools.check.isEmpty(state.IDNumberData) ||
            Tools.check.isEmpty(state.expirationDate[0].choose) ||
            Tools.check.isEmpty(state.phoneNumberData) ||
            Tools.check.isEmpty(state.emailData)
        ) {
            state.nextBtnDisabled = true

        } else state.nextBtnDisabled = false
    },


};

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}